# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=kicad-library
pkgver=5.1.5
pkgrel=2
pkgdesc="Kicad component and footprint libraries"
url="https://kicad.github.io/"
# kicad is only available on x86_64 currently :-/
arch="noarch !s390x !mips !mips64"
license="GPL-3.0-or-later"
makedepends="cmake"
depends="kicad"
subpackages="$pkgname-3d:three_d"
source="
	kicad-sym.$pkgver.tgz::https://github.com/KiCad/kicad-symbols/archive/$pkgver.tar.gz
	kicad-foot.$pkgver.tgz::https://github.com/KiCad/kicad-footprints/archive/$pkgver.tar.gz
	kicad-3d.$pkgver.tgz::https://codeload.github.com/KiCad/kicad-packages3D/tar.gz/$pkgver
	"
options="!check" # package only provides data files, so not tests possible

build() {
	cd "$srcdir"/kicad-symbols-$pkgver
	cmake . \
		-DCMAKE_INSTALL_PREFIX=/usr
	make

	cd "$srcdir"/kicad-footprints-$pkgver
	cmake . \
		-DCMAKE_INSTALL_PREFIX=/usr
	make

	cd "$srcdir"/kicad-packages3D-$pkgver
	cmake . \
		-DCMAKE_INSTALL_PREFIX=/usr
	make
}

package() {
	cd "$srcdir"/kicad-symbols-$pkgver
	make DESTDIR="$pkgdir" install

	cd "$srcdir"/kicad-footprints-$pkgver
	make DESTDIR="$pkgdir" install
}

three_d() {
	cd "$srcdir"/kicad-packages3D-$pkgver
	make DESTDIR="$subpkgdir" install

	# Remove .step version of 3D models; only .wrl versions are needed
	find "$subpkgdir" -name '*.step' -exec rm {} \;
}

sha512sums="345c7990ba17f778fa975250fbb067a01472aa6e03cbd08a1e34203af5517981b6a569981e30b4d56e58a3966c364b529b9679a96a46ef538bd5ac6a6b46eac7  kicad-sym.5.1.5.tgz
dbfb482d41d1c109e1fb395d194f700e45f1c268a33645b71cd9d98ada32369fe01dd6bf10c7f767c65b9b4e0efa6fc1bde1e4c91b9f4b751540fe3b511ba5b4  kicad-foot.5.1.5.tgz
844de269cd9c1c0c4082f09097dc853cd49a2942f621229604b9996c61f8e1c1a0b1008201ad2e13107a07b3f4601601f2d361b60b6e62984165dcdfd1dd378c  kicad-3d.5.1.5.tgz"
